import Vue from 'vue'
import VueRouter from 'vue-router'
import RouteView from '../components/layouts/RouteView'
import NavigateView from '../components/layouts/NavigateView'
import Home from '../views/Home'
import Details from '../views/GameDetails'
import My from '../views/My'
import MessageList from '../views/MessageList'
import MessageDetails from '../views/MessageDetails'
import Login from '../views/Login'
import LoginByCode from '../views/LoginByCode'

Vue.use(VueRouter)

const routes = [
  {
    name: 'Home',
    path: '/',
    redirect: '/home',
    component: RouteView,
    children: [
      {
        name: 'Message',
        path: '/home',
        component: Home,
      },
      {
        name: 'DetailsWrapper',
        meta: {parent: '/home'},
        path: '/details_wrapper',
        component: NavigateView,
        children: [
          {
            name: 'Details',
            meta: {parent: '/home', title: '比赛详情'},
            path: '/details/:id',
            component: Details,
          }
        ]
      },
      {
        name: 'My',
        path: '/my',
        component: My,
      },
      {
        meta: {parent: '/my'},
        name: 'MessageListWrapper',
        path: '/message',
        redirect: '/message_list',
        component: NavigateView,
        children: [
          {
            name: 'MessageList',
            meta: {parent: '/my', title: '消息中心'},
            path: '/message_list',
            component: MessageList
          },
          {
            meta: {parent: '/my', title: '消息详情'},
            name: 'MessageDetails',
            path: '/message/:id',
            component: MessageDetails
          }
        ]
      },
    ]
  },
  {
    name: 'Login',
    path: '/login',
	  redirect: '/login_code',
    component: Login
  },
  {
    name: 'LoginByCode',
    path: '/login_code',
    component: LoginByCode
  },
]

const router = new VueRouter({
  routes
})

export default router
